VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmORD120 
   BackColor       =   &H8000000D&
   Caption         =   "ORD120"
   ClientHeight    =   5040
   ClientLeft      =   2025
   ClientTop       =   2250
   ClientWidth     =   7710
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   ScaleHeight     =   5040
   ScaleWidth      =   7710
   Begin VB.Frame Frame1 
      BackColor       =   &H00E0E0E0&
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   2685
      Left            =   375
      TabIndex        =   10
      Top             =   1545
      Width           =   6990
      Begin VB.TextBox txtSTTEL 
         BeginProperty Font 
            Name            =   "VNI-Times"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1725
         TabIndex        =   24
         Top             =   2100
         Width           =   1890
      End
      Begin VB.TextBox txtSTSAD 
         BeginProperty Font 
            Name            =   "VNI-Times"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1725
         TabIndex        =   23
         Top             =   1650
         Width           =   2865
      End
      Begin VB.TextBox txtSTSCN 
         BeginProperty Font 
            Name            =   "VNI-Times"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1725
         TabIndex        =   22
         Top             =   1245
         Width           =   2820
      End
      Begin VB.TextBox txtSTCNM 
         BeginProperty Font 
            Name            =   "VNI-Times"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1725
         TabIndex        =   21
         Top             =   870
         Width           =   2790
      End
      Begin VB.TextBox txtSTSTN 
         BeginProperty Font 
            Name            =   "VNI-Times"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1725
         TabIndex        =   20
         Top             =   465
         Width           =   1890
      End
      Begin MSDataListLib.DataCombo cboSTCNO 
         Bindings        =   "frmORD120.frx":0000
         Height          =   375
         Left            =   1740
         TabIndex        =   19
         Top             =   90
         Visible         =   0   'False
         Width           =   3615
         _ExtentX        =   6376
         _ExtentY        =   661
         _Version        =   393216
         ListField       =   "CMNME"
         BoundColumn     =   "CMCNO"
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "VNI-Times"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VB.TextBox txtSTCNO 
         BeginProperty Font 
            Name            =   "VNI-Times"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1740
         TabIndex        =   12
         Top             =   90
         Width           =   1215
      End
      Begin VB.TextBox txtCMNME 
         BeginProperty Font 
            Name            =   "VNI-Times"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2970
         MultiLine       =   -1  'True
         TabIndex        =   11
         Top             =   90
         Width           =   2340
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Ship to"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   3
         Left            =   180
         TabIndex        =   18
         Top             =   495
         Width           =   750
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Cust No"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   5
         Left            =   180
         TabIndex        =   17
         Top             =   180
         Width           =   870
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Ship to Name"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   4
         Left            =   180
         TabIndex        =   16
         Top             =   900
         Width           =   1230
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Name of person"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   6
         Left            =   180
         TabIndex        =   15
         Top             =   1365
         Width           =   1410
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Ship to Address"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   255
         Index           =   7
         Left            =   180
         TabIndex        =   14
         Top             =   1755
         Width           =   1395
      End
      Begin VB.Label lbl 
         BackStyle       =   0  'Transparent
         Caption         =   "Ship to Tel"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   7.5
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H8000000D&
         Height          =   225
         Index           =   8
         Left            =   180
         TabIndex        =   13
         Top             =   2160
         Width           =   1080
      End
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   3765
      Top             =   45
      Visible         =   0   'False
      Width           =   1695
      _ExtentX        =   2990
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "1.EST"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "&Delete"
      Height          =   372
      Left            =   4890
      TabIndex        =   7
      Top             =   4425
      Width           =   960
   End
   Begin VB.CommandButton cmdAddnew 
      Caption         =   "&New"
      Height          =   372
      Left            =   660
      TabIndex        =   4
      Top             =   4455
      Width           =   996
   End
   Begin VB.CommandButton cmdEdit 
      Caption         =   "&Edit"
      Height          =   372
      Left            =   1725
      TabIndex        =   3
      Top             =   4425
      Width           =   948
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "&Save"
      Height          =   372
      Left            =   2760
      TabIndex        =   2
      Top             =   4425
      Width           =   984
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "&Cancel"
      Height          =   372
      Left            =   3795
      TabIndex        =   1
      Top             =   4425
      Width           =   1032
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   372
      Left            =   5910
      TabIndex        =   0
      Top             =   4425
      Width           =   1080
   End
   Begin MSDataListLib.DataCombo cboSTIDN 
      Bindings        =   "frmORD120.frx":0015
      Height          =   315
      Left            =   2640
      TabIndex        =   8
      Top             =   1065
      Width           =   3120
      _ExtentX        =   5503
      _ExtentY        =   556
      _Version        =   393216
      ListField       =   "STIDN"
      BoundColumn     =   "STIDN"
      Text            =   ""
   End
   Begin MSAdodcLib.Adodc Adodc2 
      Height          =   330
      Left            =   5550
      Top             =   60
      Visible         =   0   'False
      Width           =   1695
      _ExtentX        =   2990
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "2.RCM"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "Select Cust Ship To"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   7.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0080FFFF&
      Height          =   225
      Index           =   2
      Left            =   780
      TabIndex        =   9
      Top             =   1170
      Width           =   1605
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "ORD120"
      BeginProperty Font 
         Name            =   "VNI-Present"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   -1  'True
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   465
      Index           =   0
      Left            =   15
      TabIndex        =   6
      Top             =   30
      Width           =   1680
   End
   Begin VB.Label lbl 
      BackStyle       =   0  'Transparent
      Caption         =   "SHIP TO MAINTENANCE"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   16.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   495
      Index           =   1
      Left            =   1770
      TabIndex        =   5
      Top             =   555
      Width           =   4800
   End
End
Attribute VB_Name = "frmORD120"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim OldSTIDN As String
Private Sub WriteToFile()
Dim SQLInsert As String
If ISADDING Then
    SQLInsert = " INSERT INTO EST " & _
        "(STCNO,STSTN,STCNM,STSCN,STSAD,STTEL) " & _
        "VALUES " & _
          "('" & txtSTCNO & "', '" & txtSTSTN & "','" & txtSTCNM & "', '" & txtSTSCN & "','" & txtSTSAD & "', '" & txtSTTEL & "')"
 Else
    SQLInsert = "UPDATE EST SET STCNO = '" & txtSTCNO & "', STSTN ='" & txtSTSTN & "' " & _
    ",STCNM='" & txtSTCNM & "',STSCN= '" & txtSTSCN & "'" & _
    ",STSAD='" & txtSTSAD & "', STTEL='" & txtSTTEL & "'" & _
    " WHERE STCNO + ' - ' + STSTN='" & OldSTIDN & "'"
End If

DBconn.Execute SQLInsert
Adodc1.Refresh

End Sub

Private Sub WriteToScreen()
If ISADDING Then 'gan rong
        txtSTCNO = ""
        txtSTSTN = ""
        txtCMNME = ""
        txtSTCNM = ""
        txtSTSCN = ""
        txtSTSAD = ""
        txtSTTEL = ""
Else
        Dim TBL As Recordset
        Set TBL = DBconn.Execute("  Select EST.*From EST where  STCNO ='" & txtSTCNO & "' and STSTN='" & txtSTSTN & "'")
        If TBL.EOF = False Then
            txtSTCNO = IIf(IsNull(TBL!STCNO), "", TBL!STCNO)
            txtCMNME = Find("RCM", "CMNME", " WHERE CMCNO='" & txtSTCNO & "'")
            txtSTSTN = IIf(IsNull(TBL!STSTN), "", TBL!STSTN)
            txtSTCNM = IIf(IsNull(TBL!STCNM), "", TBL!STCNM)
            txtSTSCN = IIf(IsNull(TBL!STSCN), "", TBL!STSCN)
            txtSTSAD = IIf(IsNull(TBL!STSAD), "", TBL!STSAD)
            txtSTTEL = IIf(IsNull(TBL!STTEL), "", TBL!STTEL)
        Else
            cboSTCNO.BoundText = ""
            txtSTCNO = ""
            txtSTSTN = ""
            txtCMNME = ""
            txtSTCNM = ""
            txtSTSCN = ""
            txtSTSAD = ""
            txtSTTEL = ""
        End If
        TBL.Close
End If
OldSTIDN = txtSTCNO & " - " & txtSTSTN
End Sub

Sub ButtonStatus()
cmdAddnew.Enabled = Not ISEDITING
cmdEdit.Enabled = Not ISEDITING
cmdSave.Enabled = ISEDITING ' And txtIMITN <> ""
cmdDelete.Enabled = Not ISEDITING 'And txtIMITN <> ""
cmdCancel.Enabled = ISEDITING
Frame1.Enabled = ISEDITING

End Sub

Private Sub cboSTCNO_Click(Area As Integer)
If Area = 2 Then
    txtSTCNO = cboSTCNO.BoundText
    txtCMNME = cboSTCNO.Text
    cboSTCNO.Visible = False
    txtSTSTN.SetFocus
End If


End Sub

Private Sub cboSTIDN_Click(Area As Integer)
If Area = 2 Then
    txtSTCNO = Find("EST", "STCNO", " WHERE STCNO + ' - ' + STSTN='" & cboSTIDN.BoundText & "'")
    txtSTSTN = Find("EST", "STSTN", " WHERE STCNO + ' - ' + STSTN='" & cboSTIDN.BoundText & "'")
    WriteToScreen
End If
End Sub

Private Sub cmdAddnew_Click()
ISADDING = True
ISEDITING = True
WriteToScreen

' Ham Gan tri man hinh
ButtonStatus
txtSTCNO.SetFocus
End Sub

Private Sub cmdCancel_Click()
' Gan tri man nhinh
ISADDING = False
ISEDITING = False

ButtonStatus
txtSTCNO = cboSTCNO.BoundText
WriteToScreen


End Sub

Private Sub cmdDelete_Click()
Dim SQL As String
Response = MsgBox("Do you really to delte this Sale man?", vbYesNo + vbCritical + vbDefaultButton2, "Chu y'")
If Response = vbYes Then
        SQL = "DELETE FROM EST WHERE STCNO = '" & cboSTCNO.BoundText & "'"
        
        Set cmdExecute = New ADODB.Command
        Set cmdExecute.ActiveConnection = DBconn
        cmdExecute.CommandText = SQL
        cmdExecute.Execute
        Adodc1.Refresh
End If
'WriteToScreen (0)

End Sub

Private Sub cmdEdit_Click()
ISEDITING = True
' Ham gan tri man hinh
ISADDING = False
ISEDITING = True


ButtonStatus

End Sub

Private Sub cmdExit_Click()
Unload frmORD120
End Sub

Private Sub cmdSave_Click()


WriteToFile
Adodc1.Refresh

'''''''''''
ISADDING = False
ISEDITING = False

ButtonStatus


End Sub

Private Sub Form_Load()
'BIENCHUNG
Adodc1.ConnectionString = ConnectString
Adodc1.ConnectionTimeout = 10
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "Select  STCNO + ' - ' + STSTN as STIDN  from EST"
Adodc1.Refresh

Adodc2.ConnectionString = ConnectString
Adodc2.ConnectionTimeout = 10
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "Select * from RCM WHERE CMRID<>'RZ'"
Adodc2.Refresh
ISADDING = False
ISEDITING = False
ButtonStatus

End Sub



Private Sub txtSTCNM_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
   txtSTSCN.SetFocus
End If
End Sub

Private Sub txtSTCNO_KeyPress(KeyAscii As Integer)
Dim Result As String
If KeyAscii = 13 Then
    Result = Find("RCM", "CMNME", "WHERE CMCNO='" & txtSTCNO & "'")
    If Result = "" Then
        cboSTCNO.Visible = True
        cboSTCNO.SetFocus
    Else
        cboSTCNO.Visible = False
        txtCMNME = Result
        txtSTSTN.SetFocus
    End If
End If


End Sub

Private Sub txtSTSAD_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    txtSTTEL.SetFocus
End If
End Sub

Private Sub txtSTSCN_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    txtSTSAD.SetFocus
End If
End Sub

Private Sub txtSTSTN_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    If ValidMaso(OldSTCNO, txtSTCNO & " - " & txtSTSTN, "EST", " STCNO='" & txtSTCNO & "' AND STSTN='" & txtSTSTN & "'") Then
        MsgBox "This code is already exist"
        txtSTCNO.SetFocus
    Else
        txtSTCNM.SetFocus
    End If
End If

End Sub

Private Sub txtSTTEL_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then cmdSave.SetFocus
End Sub
